package sdk.webview.fmc.com.fmcsdk.check.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.VideoView;

import com.bumptech.glide.Glide;
import com.github.chrisbanes.photoview.PhotoView;

import java.util.List;

import sdk.webview.fmc.com.fmcsdk.check.bean.ImageSelectBean;

public class ImagePagerAdapter extends PagerAdapter {

    private List<ImageSelectBean> list;
    private Context context;

    public ImagePagerAdapter(Context context, List<ImageSelectBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        Log.e("huohuohuohuo",position+"");
        // 获取当前图片的URL
        ImageSelectBean imageSelectBean = list.get(position);
            // 加载图片并设置为 PhotoView 的内容
            PhotoView photoView = new PhotoView(context);
            Glide.with(context).load(imageSelectBean.getImg()).into(photoView); // 使用 Picasso 加载图片，可以换成 Glide 或其他方式
            container.addView(photoView);
            return photoView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public boolean isViewFromObject(@NonNull @androidx.annotation.NonNull View view, @NonNull @androidx.annotation.NonNull Object o) {
        return view == o;
    }
}
